#include <bits/stdc++.h>
using namespace std;

char buf[(int) 5e7], *fs = buf;

inline int gn()  {
    int k = 0;
    char c = *fs++;
    for (; !isdigit(c); c = *fs++);
    for (; isdigit(c); c = *fs++) k = k * 10 + c - '0';
    return k;
}

const int maxn = 1e5 + 3;

int x[maxn], y[maxn];

inline bool check(int t, int a, int b) { // (a, b) 是不是在 t 上或上面 
    double k = (double) y[t] / x[t];
    return (double) b >= (double) -1 * a * k + (double) y[t];
}

int main() {
    freopen("geometry.in", "r", stdin);
    freopen("geometry.out", "w", stdout);
    fread(buf, 1, (int) 5e7, stdin);
    int n = gn();
    for (int i = 1; i <= n; i++) {
        x[i] = gn();
    }
    for (int i = 1; i <= n; i++) {
        y[i] = gn();
    }
    sort(x + 1, x + 1 + n);
    sort(y + 1, y + 1 + n);
    int m = gn();   
    for (int i = 1; i <= m; i++) {
        int a = gn(), b = gn(), l = 0, r = n, mid;
        while (l + 1 < r) {
            mid = (l + r) >> 1;
            if (check(mid, a, b)) l = mid;
            else r = mid - 1;
        }
        if (!r) printf("%d\n", 0);
        else if (check(r, a, b)) printf("%d\n", r);
        else printf("%d\n", l);
    }
}